package com.wlts.wzy.KSUserModule.util;

import com.wlts.wzy.KSUserModule.entity.KsOauth;
import com.wlts.wzy.KSUserModule.entity.KsStoreUser;
import com.wlts.wzy.KSUserModule.service.IKsOauthService;
import com.wlts.wzy.expand.MyLambdaQueryWrapper;
import com.wlts.wzy.util.LoginUserUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class KsConfig {

    @Autowired
    private IKsOauthService ksOauthService;


    public KsStoreUser getKsStoreUserConfig() {

        Subject subject = SecurityUtils.getSubject();

        KsStoreUser storeUser = LoginUserUtil.getLoginKsStoreUser(subject);

        MyLambdaQueryWrapper<KsOauth> queryWrapper = new MyLambdaQueryWrapper<>();

        queryWrapper.eq(KsOauth::getUserUuid, storeUser.getUuid());

        storeUser.setKsOauth(ksOauthService.getOne(queryWrapper));

        return storeUser;

    }


    public KsOauth getKsConfig(String userUuid) {


        MyLambdaQueryWrapper<KsOauth> queryWrapper = new MyLambdaQueryWrapper<>();

        queryWrapper.eq(KsOauth::getUserUuid, userUuid);

        return ksOauthService.getOne(queryWrapper);

    }

}
